package com.ddtech.business.course.controller;


import com.ddtech.business.course.query.CourseStudyRecordQuery;
import com.ddtech.business.course.service.CourseStudyRecordService;
import com.ddtech.business.course.vo.req.CourseStudyReq;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程学习记录表 前端控制器
 * </p>
 *
 * @author bin_pu
 * @since 2023-02-06
 */
@Api(tags = "业务-课程学习进度")
@RestController
@RequestMapping("/course/study-record")
public class CourseStudyRecordController {
    @Autowired
    private CourseStudyRecordService courseStudyRecordService;

    @ApiOperation(value = "查询课程学习进度")
    @GetMapping(value = "/page-list")
    public ResponseEntity getPageList(CourseStudyRecordQuery courseQuery) {
        return new ResponseEntity(courseStudyRecordService.pageList(courseQuery), HttpStatus.OK);
    }

    @ApiOperation(value = "保存学习记录")
    @PostMapping(value = "/create")
    public ResponseEntity create(@Validated @RequestBody CourseStudyReq courseStudyReq) {
        courseStudyRecordService.create(courseStudyReq);
        return new ResponseEntity(HttpStatus.OK);
    }
}
